﻿using System;
using System.Collections.Generic;
using System.Text;
//new
using JRCore.protocol;
using System.Threading;
using DataRecv.enums;
using DataRecv.models.road;
using System.Collections;

namespace DataRecv.models.device
{
    /// <summary>
    /// 设备类
    /// </summary>
    public abstract class Device
    {
        /// <summary>
        /// 设备校时定时器
        /// </summary>
        public Timer m_TimeAdjuster;
        /// <summary>
        /// 注册布防定时器
        /// </summary>
        public Timer m_InitTimer;
        /// <summary>
        /// 设备能力
        /// </summary>
        public static Enum_CaptureSystem Ability = Enum_CaptureSystem.NONE;
        public DeviceView deviceview;
        public DeviceState state;
        public delegate void StateChanged(string camip, bool online);
        public static event StateChanged OnStateChangedEvent;
        public StateChanged PingReport;
        public abstract void Init(object obj);
        public abstract void ShutDown();
        public abstract void AdjustTime(object obj);
        

        public void Run()
        {
            Thread t = new Thread(new ThreadStart(T));
            t.Start();
        }

        private void T()
        { 
            m_InitTimer = new Timer(new TimerCallback(Init), null, 5000, 60000);
            m_TimeAdjuster = new Timer(new TimerCallback(AdjustTime), null, 3600000, 3600000);
            PingReport = new StateChanged(PingReportTrigger);
        }

        private void PingReportTrigger(string camip, bool online)
        {
            if (OnStateChangedEvent != null) OnStateChangedEvent(camip, online);
        }

        //public abstract void Restart();
        //public abstract DataRecvRecord RecordData(object obj);
        //public abstract void Init();
        //public abstract void Login();
        //public abstract void StartPreView(IntPtr handle);
        //public abstract void StopPreView();
        //public abstract void Logout();
        //public abstract DateTime GetDeviceTime();

        
    }
}
